package cn.itcast.zt.util;

import cn.itcast.zt.exceptions.CheckException;

import java.util.stream.Stream;

/**
 * created by zhangtian on 2018/7/9
 */
public class CheckUtil {
    private static final String[] INVALID_NAMES = {"admin", "guanliyuan"} ;
    /**
     * 校验名称，校验不成功抛出校验异常
     * @param value
     */
    public static void checkName(String value) {
        Stream.of(INVALID_NAMES).filter(name->name.equalsIgnoreCase(value))
                .findAny().ifPresent(name->{
                    throw new CheckException("name", value) ;
        });
    }
}
